package com.yunhe.common.model.data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 告警公式对象
 * 因为该对象主要会放在缓存中使用
 * 而List<Long>或者Map<Long,Xxx>这种泛型对象，一旦序列化，会出现类型擦除的问题
 * 故为了避免这种问题，将List<Long>定义为List<String>，在setter和getter中进行转换
 */
public class AbnormalRuleFormulaObject implements Serializable {
    private Long abnormalRuleId;
    private Long alarmLevelId;
    private String formula;
    private List<String> measPointNumbers;
    private List<String> relatedPointNumbers;
    //    private Long pointNumber;
    private String description;

    public Long getAbnormalRuleId() {
        return abnormalRuleId;
    }

    public void setAbnormalRuleId(Long abnormalRuleId) {
        this.abnormalRuleId = abnormalRuleId;
    }

    public Long getAlarmLevelId() {
        return alarmLevelId;
    }

    public void setAlarmLevelId(Long alarmLevelId) {
        this.alarmLevelId = alarmLevelId;
    }

    public String getFormula() {
        return formula;
    }

    public void setFormula(String formula) {
        this.formula = formula;
    }

    public List<Long> getMeasPointNumbers() {
        return this.measPointNumbers == null ? null : this.measPointNumbers.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
    }

    public void setMeasPointNumbers(List<Long> measPointNumbers) {
        this.measPointNumbers = measPointNumbers == null ? null : measPointNumbers.stream().map(String::valueOf).collect(Collectors.toList());
    }

    public List<Long> getRelatedPointNumbers() {
        return this.relatedPointNumbers == null ? null : this.relatedPointNumbers.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
    }

    public void setRelatedPointNumbers(List<Long> relatedPointNumbers) {
        this.relatedPointNumbers = relatedPointNumbers == null ? null : relatedPointNumbers.stream().map(String::valueOf).collect(Collectors.toList());
    }

//    public Long getPointNumber() {
//        return pointNumber;
//    }
//
//    public void setPointNumber(Long pointNumber) {
//        this.pointNumber = pointNumber;
//    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "AbnormalRuleFormulaObject{" +
                "abnormalRuleId=" + abnormalRuleId +
                ", alarmLevelId=" + alarmLevelId +
                ", formula='" + formula + '\'' +
                ", measPointNumbers=" + measPointNumbers +
                ", relatedPointNumbers=" + relatedPointNumbers +
                ", description='" + description + '\'' +
                '}';
    }
}
